package com.cw.jeeyt.service.converter.process;

import java.util.ArrayList;
import java.util.List;

import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import com.cw.jeeyt.service.bo.process.ActReProcdefBo;
import com.cw.jeeyt.dao.model.process.ActReProcdefDo;
import com.cw.lang.common.utils.CollectionUtil;

/**
 * 流程定义转换类
 *
 * @author chenw
 * @date 2019-03-13 22:15:39
 */
public class ActReProcdefConverter {

    /**
     * do转bo
     *
     * @param model
     * @return
     */
    public static ActReProcdefBo do2Bo(ActReProcdefDo model) {
        if (model == null) {
            return null;
        }
        ActReProcdefBo bo = new ActReProcdefBo();
        bo.setId_(model.getId_());
        bo.setRev_(model.getRev_());
        bo.setCategory_(model.getCategory_());
        bo.setName_(model.getName_());
        bo.setKey_(model.getKey_());
        bo.setVersion_(model.getVersion_());
        bo.setDeploymentId_(model.getDeploymentId_());
        bo.setResourceName_(model.getResourceName_());
        bo.setDgrmResourceName_(model.getDgrmResourceName_());
        bo.setDescription_(model.getDescription_());
        bo.setHasStartFormKey_(model.getHasStartFormKey_());
        bo.setHasGraphicalNotation_(model.getHasGraphicalNotation_());
        bo.setSuspensionState_(model.getSuspensionState_());
        bo.setTenantId_(model.getTenantId_());
        bo.setEngineVersion_(model.getEngineVersion_());
        bo.setDerivedFrom_(model.getDerivedFrom_());
        bo.setDerivedFromRoot_(model.getDerivedFromRoot_());
        bo.setDerivedVersion_(model.getDerivedVersion_());
        return bo;
    }

    /**
     * bo转do
     *
     * @param bo
     * @return
     */
    public static ActReProcdefDo bo2Do(ActReProcdefBo bo) {
        if (bo == null) {
            return null;
        }
        ActReProcdefDo model = new ActReProcdefDo();
        model.setId_(bo.getId_());
        model.setRev_(bo.getRev_());
        model.setCategory_(bo.getCategory_());
        model.setName_(bo.getName_());
        model.setKey_(bo.getKey_());
        model.setVersion_(bo.getVersion_());
        model.setDeploymentId_(bo.getDeploymentId_());
        model.setResourceName_(bo.getResourceName_());
        model.setDgrmResourceName_(bo.getDgrmResourceName_());
        model.setDescription_(bo.getDescription_());
        model.setHasStartFormKey_(bo.getHasStartFormKey_());
        model.setHasGraphicalNotation_(bo.getHasGraphicalNotation_());
        model.setSuspensionState_(bo.getSuspensionState_());
        model.setTenantId_(bo.getTenantId_());
        model.setEngineVersion_(bo.getEngineVersion_());
        model.setDerivedFrom_(bo.getDerivedFrom_());
        model.setDerivedFromRoot_(bo.getDerivedFromRoot_());
        model.setDerivedVersion_(bo.getDerivedVersion_());
        return model;
    }

    /**
     * doList转boList
     *
     * @param doList
     * @return
     */
    public static List<ActReProcdefBo> doList2BoList(List<ActReProcdefDo> doList) {
        if (CollectionUtil.isEmpty(doList)) {
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(doList.iterator(), ActReProcdefConverter::do2Bo));
    }

    /**
     * boList转doList
     *
     * @param boList
     * @return
     */
    public static List<ActReProcdefDo> boList2DoList(List<ActReProcdefBo> boList) {
        if (CollectionUtil.isEmpty(boList)) {
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(boList.iterator(), ActReProcdefConverter::bo2Do));
    }
}